package mspdt.pocket.wallet;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TimePicker;

public class EditActivity extends Activity{
	
	private EditText amount_value, desc_value;
	private Button btn_save_and_new, btn_save_and_close;
	private DatePicker date_picker;
	private TimePicker time_picker;
	private Spinner prg_chooser, group_chooser, category_chooser, account_chooser, deb_acc_chooser, kre_acc_chooser;
	String amount_str, desc_str, year, month, day, hour, minute, prg, group, category, account, deb_str, kre_str;
	SpinnerAdapter prg_adapter, group_adapter, category_adapter, account_adapter, deb_adapter, kre_adapter;
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.edit_activity);
		
		
		Bundle bundle = getIntent().getExtras();
		amount_str = bundle.getString("amount");
		desc_str = bundle.getString("description");
		year = bundle.getString("year");
		month = bundle.getString("month");
		day = bundle.getString("day");
		hour = bundle.getString("hour");
		minute = bundle.getString("minute");
		prg = bundle.getString("prg");
		group = bundle.getString("group");
		category = bundle.getString("category");
		account = bundle.getString("account");
		deb_str = bundle.getString("deb_str");
		kre_str = bundle.getString("kre_str");
		
		
		amount_value = (EditText)findViewById(R.id.edit_screen_et_amount);
		amount_value.setText(amount_str);
		desc_value = (EditText)findViewById(R.id.edit_screen_et_description);
		desc_value.setText(desc_str);
		
		btn_save_and_new = (Button)findViewById(R.id.edit_screen_save_and_new);
		btn_save_and_close = (Button)findViewById(R.id.edit_screen_save_and_close);
		
		date_picker = (DatePicker)findViewById(R.id.edit_screen_datepicker);
		date_picker.updateDate(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day));
		time_picker = (TimePicker)findViewById(R.id.edit_screen_timepicker);
		time_picker.setCurrentHour(Integer.parseInt(hour));
		time_picker.setCurrentMinute(Integer.parseInt(minute));
		
		prg_chooser = (Spinner)findViewById(R.id.edit_screen_prg);
		group_chooser = (Spinner)findViewById(R.id.edit_screen_prg_group);
		category_chooser = (Spinner)findViewById(R.id.edit_screen_prg_category);
		account_chooser = (Spinner)findViewById(R.id.edit_screen_choose_account);
		deb_acc_chooser = (Spinner)findViewById(R.id.edit_screen_to_account);
		kre_acc_chooser = (Spinner)findViewById(R.id.edit_screen_from_account);
		
//		prg_chooser.setSelection(Integer.parseInt(prg), true);
//		group_chooser.setSelection(Integer.parseInt(group), true);
//		category_chooser.setSelection(Integer.parseInt(category), true);
//		account_chooser.setSelection(Integer.parseInt(account), true);
//		deb_acc_chooser.setSelection(Integer.parseInt(deb_str), true);
//		kre_acc_chooser.setSelection(Integer.parseInt(kre_str), true);
	}

}
